<?php
declare (strict_types = 1);
namespace app\circle\service;

use Exception;
use think\db\exception\DbException;
use think\facade\Request;
use app\common\service\BaseService;
use app\circle\logic\{Circle as CircleLogic, Comment, Like};
use think\Response;

/**
 * 圈子接口处理类
 */
class Circle extends BaseService
{

    /**
     * 发布圈子
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-05-14
     *
     * @return Response [type] [description]
     */
	public function createCircle()
	{
		$param = Request::post();

		$data = app(CircleLogic::class)->createCircle($param);

		return $this->parseToData($data, 1, '发布成功');
	}

    /**
     * 删除圈子
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-05-14
     *
     * @return Response [type] [description]
     */
	public function deleteCircle()
	{
		$param = Request::delete();

		$data = app(CircleLogic::class)->deleteCircle($param);

		return $this->parseToData($data, 1, '删除成功');
	}

    /**
     * 圈子列表
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-05-14
     *
     * @return Response [type] [description]
     * @throws DbException
     */
	public function getCircleList()
	{
		$param = Request::get();

		$data = app(CircleLogic::class)->getCircleList($param);

		return $this->parseToData($data, 1, '获取成功');
	}

    /**
     * 转载圈子时渲染数据
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-05-14
     *
     * @return Response [type] [description]
     */
	public function recircleFetch()
	{
		$param = Request::get();

		$data = app(CircleLogic::class)->recircleFetch($param);

		return $this->parseToData($data, 1, '获取成功');
	}

    /**
     * 转载圈子
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-05-14
     *
     * @return Response [type] [description]
     * @throws Exception
     */
	public function recircle()
	{
		$param = Request::post();

		$data = app(CircleLogic::class)->recircle($param);

		return $this->parseToData($data, 1, '转载成功');
	}

    /**
     * 评论圈子或回复评论
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-05-14
     *
     * @return Response [type] [description]
     * @throws Exception
     */
	public function comment()
	{
		$param = Request::post();

		$data = app(Comment::class)->createComment($param);

		return $this->parseToData($data, 1, '评论成功');
	}

    /**
     * 删除评论
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-05-14
     *
     * @return Response [type] [description]
     */
	public function deleteComment()
	{
		$param = Request::delete();

		$data = app(Comment::class)->deleteComment($param);

		return $this->parseToData($data, 1, '删除成功');
	}

    /**
     * 评论圈子或回复评论
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-05-14
     *
     * @return Response [type] [description]
     * @throws Exception
     */
	public function like()
	{
		$param = Request::post();

		$data = app(Like::class)->like($param);

		return $this->parseToData($data, 1, '操作成功');
	}

    /**
     * 圈子详情
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-05-14
     *
     * @return Response [type]        [description]
     */
	public function getCircle()
	{

		$param = Request::get();

		$data = app(CircleLogic::class)->getCircle($param);

		return $this->parseToData($data, 1, '获取成功');
	}

    /**
     * 我的圈子列表
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-05-14
     *
     * @return Response [type]        [description]
     */
	public function getMyCircleList()
	{

		$data = app(CircleLogic::class)->getMyCircleList();

		return $this->parseToData($data, 1, '获取成功');
	}

    /**
     * 用户圈子列表
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-05-14
     *
     * @return Response [type]        [description]
     */
	public function getUserCircleList()
	{
		$param 	= Request::get();
		$data 	= app(CircleLogic::class)->getUserCircleList($param);

		return $this->parseToData($data, 1, '获取成功');
	}


}
